#include "stdafx.h"
#include "VSCtxMenuFixApp.h"

static WCHAR g_szAppMutexName[] = L"VSCtxMenuFixApp:74ab1cb0-59f5-4192-9cc1-fb19fb54d921";

CMyAppMutex::CMyAppMutex()
{
    m_Success = FALSE;
    m_hAppMutex = NULL;

    HANDLE hMutex = CreateMutex(NULL, TRUE, g_szAppMutexName);

    if (!hMutex)
    {
        return;
    }

    if (GetLastError() == ERROR_ALREADY_EXISTS)
    {
        CloseHandle(hMutex);
        return;
    }

    m_Success = TRUE;
    m_hAppMutex = hMutex;
}

CMyAppMutex::~CMyAppMutex()
{
    if (m_hAppMutex)
    {
        CloseHandle(m_hAppMutex);
    }
}
